home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_3 / issue10 / hints / viewsheet / !ViewSheet / !Convert / Convert (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1993-11-29  |  6.5 KB  |  168 lines

  1.  >Convert_4    Ver. 3.3
  2.  By D.J.Holden  Jan 1990
  3.  Converts BBC View, Viewsheet or Viewstore
  4.  ROM into a Module for the Archimedes
  5.  Expects to find Headcode in !Convert dir and ROM in parent dir
  6.  Works for;
  7.  View A3, B3.1, B3.11  (bug in earlier Bxx version fixed)
  8.  ViewSheet 1.0, B1.0, B1.01
  9.  Viewstore 1.1, 1.13
  10.  Set rom$ to View, VSheet or VStore
  11.  Must be these names exactly with same case
  12. rom$="VSheet":ver$=""
  13.  buffer% &4C00, code% &100
  14.  "OS_File",17,"<Obey$Dir>.^."+rom$ 
  15.  found%
  16.  found%<> 1 
  17. "Unable to find "rom$" ROM.":
  18.  "OS_File",17,"<Obey$Dir>.Header" 
  19.  found%,,,,h_len%
  20.  found%<>1 
  21. Unable to find Header code.":
  22.  "OS_File",17,"<Obey$Dir>.Patch_Code" 
  23.  found%,,,,p_len%
  24.  found%<>1 
  25. Unable to find 6502 Patch Code.":
  26. rom%=buffer%+h_len%
  27.  "OS_File",16,"<Obey$Dir>.Header",buffer%,0
  28.  "OS_File",16,"<Obey$Dir>.^."+rom$,rom%,0
  29.  "OS_File",16,"<Obey$Dir>.Patch_Code",rom%+&4000,0
  30. assemble
  31.  Ensure ROM type byte identifies it as a language so it will
  32.  work properly with 65Tube. This may have been changed for SWR
  33. rom%?6=&C2
  34.  rom%!16=&42007465 
  35.  rom%!20=&00302E31:
  36.  rom$="VSheet" 
  37. sheet_B1
  38.  rom%!16=&42007465 
  39.  rom%!20=&31302E31:
  40.  rom$="VSheet" 
  41. full:ver$=" View Sheet B1.1"
  42.  rom%!16=&31007465 
  43.  rom%!20=&2800302E:
  44.  rom$="VSheet" 
  45. full:ver$=" View Sheet 1.0"
  46.  rom%!16=&31006572 
  47.  rom%!20=&2800312E:
  48.  rom$="VStore" 
  49. store_11
  50.  rom%!16=&31006572 
  51.  rom%!20=&0033312E:
  52.  rom$="VStore" 
  53. full:ver$=" View Store 1.13"
  54. *** STILL BUGS WHEN rom%!16=&31006572 AND rom%!20=&2800322E:IF rom$="VStore" PROCfull:ver$=" View Store 1.2"
  55.  rom%?&2842=
  56.  rom$="View" 
  57. view_B0
  58.  rom%!&2A58=&00312E33:
  59.  rom$="View" 
  60. full:ver$=" View B3.1"
  61.  rom%!&2878=&00302E33:
  62.  rom$="View" 
  63. view_A0
  64.  rom%!&2A58=&31312E33:
  65.  rom$="View" 
  66. full:ver$=" View B3.11"
  67.  ver$="" 
  68. Don't recognise this version of "rom$
  69. '"  Do you wish to attemp a conversion anyway  Y/N ? ";
  70. ''"  Conversion abandoned":
  71. ''"  Try FULL conversion with function key correction  Y/N ? ";
  72. 4! ver$=rom$+", type unknown, "
  73. full:ver$=ver$+"full" 
  74.  ver$=ver$+"partial"
  75.  "copy <Obey$Dir>.Run1 <Obey$Dir>.^.!Run ~V F ~C"
  76.   ========================================================
  77.   Use the following line if you just want to
  78.   convert the ROM and not make it into a Module
  79.   SYS "OS_File",10,"<Obey$Dir>.^.Arc"+rom$,&BBC,,rom%,rom%+&4100:END
  80.   ========================================================
  81.  "OS_File",10,"<Obey$Dir>.^."+rom$+"Mod",&FFA,,buffer%,rom%+&4100
  82. ''"  "ver$" conversion successful."
  83. ver$,"unknown") 
  84. '"  Although the ROM has been converted it may not operate"
  85.  "  properly. If there are problems then send me a copy of"
  86.  "  it (with SAE please) and I will try to get it to work."
  87.   ===============================================================
  88.   This PROC called for full conversion only. Redirects all OSRDCH
  89.   calls to 'patch' and calls 'patch' before main Language entry
  90.   ===============================================================
  91. B%=rom%:
  92.  code%
  93. O;   
  94.  poke values for original language entry into patch
  95. P'rom%?&4066=rom%?1:rom%?&4067=rom%?2
  96. Q;   
  97.  poke new language entry at &C068 into start of ROM
  98. rom%?1=&68:rom%?2=&C0
  99.   =================================================================
  100.   These are the conversion routines for individulal ROMs. The main
  101.   item disables the routines which deliberately crash the ROM when
  102.   run in RAM. This was intended to stop the program being used in
  103.   SWR on a BBC but it was as useful as every other form of software
  104.   protection, ie. it was no bar to the dishonest and an inconvenience
  105.   to the honest, since you can see how easy it is to remove it!
  106.   =================================================================
  107. view_A0       :
  108.   For View A3.0
  109. `*rom%?&CF=&EA:rom%?&D0=&EA:rom%?&D1=&EA
  110. a0rom%?&28D6=&EA:rom%?&28D7=&EA:rom%?&28D8=&EA
  111. ver$=" View A3.0"
  112. view_B0       :
  113.   For View B3.0
  114. g*rom%?&C2=&EA:rom%?&C3=&EA:rom%?&C4=&EA
  115. h0rom%?&28A1=&EA:rom%?&28A2=&EA:rom%?&28A3=&EA
  116. ver$=" View B3.0"
  117. sheet_B1       :
  118.   For ViewSheet B1.0
  119. n-rom%?&690=&EA:rom%?&691=&EA:rom%?&692=&EA
  120. ver$=" View Sheet B1.0"
  121. store_11      :
  122.  for ViewStore 1.1
  123. t0rom%?&2BE2=&EA:rom%?&2BE3=&EA:rom%?&2BE4=&EA
  124. ver$=" View Store 1.1"
  125. xG     ==============================================================
  126. yC     Assembles the code which searches through the ROM code and
  127. zA     redirects all calls to OSrdch to the 'patch' at the end.
  128. {G     Removes all calls to OSbyte &82 to disable 2nd proc relocation
  129. |G     ==============================================================
  130. assemble
  131.  PASS=4
  132. P%=0:O%=code%
  133. [OPT PASS
  134. 2        add r2,r1,#&4000        ;r2=end of ROM
  135. 0.loop   cmp r1,r2               ;at end yet?
  136. ;        movge pc,r14            ;yes so return to BASIC
  137. 2        ldrb r0,[r1],#1         ;get next byte
  138. D        cmp r0,#&20             ;is it a JMP or JSR instruction?
  139.         cmpne r0,#&4C
  140.         bne loop
  141. M        ldrb r0,[r1,#1]         ;JMP or JSR found, get hi byte of address
  142.         cmp r0,#&FF
  143. D        bne loop                ;hi byte not &FF so keep looking
  144. ;        ldrb r0,[r1]            ;get lo byte of address
  145.         cmp r0,#&E0
  146. H        moveq r0,#0             ;if it was OSRDCH change it to &C000
  147.         streqb r0,[r1]
  148.         moveq r0,#&C0
  149.         streqb r0,[r1,#1]
  150. 9        beq loop                ;and carry on looking
  151. 5        cmp r0,#&F4             ;check for OSBYTE
  152.         bne loop
  153. D        ldrb r0,[r1,#-3]        ;check if the instruction before
  154. ;        cmp r0,#&A9             ;JSR OSBYTE is LDA #&82
  155.         ldreqb r0,[r1,#-2]
  156.         cmpeq r0,#&82
  157. 3        bne loop                ;not OSBYTE &82
  158. @        mov r0,#&A2             ;replace LDA#&82  JSR OSBYTE
  159. ;        strb r0,[r1,#-3]        ;with LDX#0  LDY#0  NOP
  160. L        mov r0,#0               ;to disable 2nd proc relocation routines
  161.         strb r0,[r1,#-2]
  162.         strb r0,[r1]
  163.         mov r0,#&A0
  164.         strb r0,[r1,#-1]
  165.         mov r0,#&EA
  166.         strb r0,[r1,#1]!
  167.         bal loop
  168.